package gamesys.games.particlesystem.graphics
{
	import flash.display.BitmapData;

	/**
	 * @author robertthurston
	 */
	public class BitmapAnimation extends Object
	{
		private var _frames : Array;
		private var _currentFrame : int;
		public var totalFrames : int;
		public var width : Number;
		public var height : Number;
		public var x : Number;
		public var y : Number;

		public function BitmapAnimation(frames : Array, randomStartFrame : Boolean = false)
		{
			_frames = frames;

			totalFrames = frames.length;
			_currentFrame = (randomStartFrame) ? Math.floor(Math.random() * totalFrames) : 0;
		}

		public function getNextFrame() : BitmapData
		{
			var bitmapData : BitmapData = _frames[_currentFrame];

			_currentFrame = ++_currentFrame % totalFrames;

			return bitmapData;
		}

		public function getFrame(frame : int) : BitmapData
		{
			return 	_frames[frame - 1];
		}

		public function get currentFrame() : int
		{
			return _currentFrame;
		}
	}
}
